package com.mall.common.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mall.b2c.util.JsonDataGridHelper;
import com.mall.common.bean.Pager;
import com.mall.common.bean.SearchFilter;
import com.mall.common.enums.MessageStatus;
import com.mall.common.enums.MessageType;
import com.mall.common.service.MessageSendService;
import com.mall.common.util.EnumUtils;
import com.mall.common.web.Servlets;
/**
 * 后台Action类 - 短信
 * @author liuzhenxing
 *
 */
@Controller
@RequestMapping("/admin/system/smsMessage")
public class SmsmessageController extends BaseController {

	@Resource private MessageSendService messageSendService;
	
	/**
	 * 短信列表
	 * @return
	 */
	@RequestMapping(value="/list",method=RequestMethod.GET)
	public String list(Model model){
		model.addAttribute("messageStatusList", EnumUtils.enumProp2I18nList(MessageStatus.class));
		model.addAttribute("messageTypeList", EnumUtils.enumProp2I18nList(MessageType.class));
		return "/admin/system/sms/list";	
	}
	
	@RequestMapping("/queryData")
	@ResponseBody
	public Pager queryData(Pager pager,HttpServletRequest request){
		Map<String, Object> filterParams = Servlets.getParametersStartingWith(request);
		List<SearchFilter> filters = SearchFilter.parse(filterParams);
		pager = messageSendService.findPage(pager, filters);
		return JsonDataGridHelper.createJSONData(pager);
	}

}
